import request from '@/utils/request'

/**
 * 获取员工列表
 * @param {*} params
 * @returns Promise<Object>
 */
export const emGetEmployeeListApi = (params) => request.get('/sys/user', { params })

/**
 * 导出员工的excel
 * @returns Promise<Blob>
 */
export const emExportEmployeeAPi = () => request.get('/sys/user/export', { responseType: 'blob' })

/**
 * 下载导入模版
 * @returns Promise<Blob>
 */
export const emDownloadTemplateAPi = () => request.get('/sys/user/import/template', { responseType: 'blob' })

/**
 * 上传员工excel
 * @param {*} data form-data
 * @returns Promise<null>
 */
export const emUploadEmployeeExcelAPi = (data) => request.post('/sys/user/import', data)

/**
 * 删除员工
 * @param {*} id 员工 id
 * @returns Promise<null>
 */
export const emDelEmployeeApi = (id) => request.delete(`/sys/user/${id}`)

/**
 * 新增员工
 * @param {*} data
 * @returns Promise<Object>
 */
export const emAddEmployeeApi = (data) => request.post('/sys/user', data)

/**
 * 获取员工信息详情
 * @param {*} id 员工 id
 * @returns Promise<Object>
 */
export const emGetEmployeeDetailApi = (id) => request.get(`/sys/user/${id}`)

/**
 * 修改员工详情
 * @param {*} data
 * @returns Promise<Object>
 */
export const emUpdateEmployeeDetailApi = (data) => request.put(`/sys/user/${data.id}`, data)

/**
 * 获取已启用角色列表
 * @returns Promise<[]>
 */
export const emGetRoleListApi = () => request.get('/sys/role/list/enabled')

/**
 * 分配员工角色
 * @param {*} data
 * @returns Promise<Object>
 */
export const emAssignRolesApi = (data) => request.put('/sys/user/assignRoles', data)
